/**
 * 版权所有：2020，TLF工作室。
 */
package com.cqeec.gams.controller;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cqeec.gams.entity.FunctionalModule;
import com.cqeec.gams.service.FunctionalModuleService;

/**
 * @author 唐礼飞
 * @date 2020-06-05 10:33:15.757
 */
@RestController
@RequestMapping("/api/function/")
public class FunctionRestController {
	@Autowired
	private FunctionalModuleService fmService;

	@GetMapping("/list")
	public List<FunctionalModule> list() {
		List<FunctionalModule> list = fmService.getAll();
		return list;
	}

	@PostMapping("/change/disabled")
	public Map<String, Object> changeDisabled(String id, String checked) {
		Map<String, Object> map = new HashMap<>();
		try {
			fmService.changeDisabled(id, "true".equals(checked));
			map.put("code", 0);
			map.put("message", "状态更改成功！");
		} catch (Exception ex) {
			ex.printStackTrace();
			map.put("code", 1);
			map.put("message", "状态更改失败！");
		}
		return map;
	}
}
